package com.project.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.project.bean.RoomBean;
import com.project.service.IRoomService;
import org.apache.coyote.http2.Http2AsyncUpgradeHandler;
import org.apache.ibatis.annotations.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("room")
public class RoomController {

    @Autowired
    private IRoomService service;

    @RequestMapping("findByItem")
    public PageInfo<RoomBean> findByItem(Integer pageNo,
                                         String address, Integer startPrice, Integer endPrice){

        return service.findByItem(pageNo,address,startPrice,endPrice);
    }

    @RequestMapping("add")
    public String addRoom(RoomBean room){
        service.add(room);
        return "ok";
    }

    @RequestMapping("del")
    public String del(int id){
        service.del(id);

        return "ok";
    }

    @RequestMapping("findById")
    public RoomBean findById(int id){
        return service.findById(id);
    }

    @RequestMapping("update")
    public String update(int id,int price){
        service.update(id,price);
        return "ok";
    }
}
